using System.Configuration;
using System.Data.Entity;
using CrawlerFramework.Models.Mapping;

namespace CrawlerFramework.Models
{
    public partial class CrawlerDbContext : DbContext
    {
        //private static readonly string ConnectionString;
        static CrawlerDbContext()
        {
            Database.SetInitializer(new CreateDatabaseIfNotExists<CrawlerDbContext>());
        }

        public CrawlerDbContext():base("CrawlDatabaseContext")
        {
            
        }

        public DbSet<CrawlHistory> CrawlHistories { get; set; }
        //public DbSet<CrawlStatusDefinition> CrawlStatusDefinitions { get; set; }
        public DbSet<Link> Links { get; set; }
        public DbSet<Log> Logs { get; set; }
        public DbSet<ScheduledJob> ScheduledJobs { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new CrawlHistoryMap());
            //modelBuilder.Configurations.Add(new CrawlStatusDefinitionMap());

            modelBuilder.Configurations.Add(new LinkMap());
            modelBuilder.Configurations.Add(new LogMap());
            
            modelBuilder.Configurations.Add(new ScheduledJobMap());

        }
    }
}
